home *** CD-ROM | disk | FTP | other *** search
/ System Booster / System Booster.iso / Commodities / CxKiller / CxKiller.c.bak < prev    next >
Text File  |  1996-09-26  |  3KB  |  114 lines

  1. /*
  2. **  CxKiller.c : Gael Marziou
  3. **
  4. **  A simple program to kill Commodties safely.
  5. **  Without any argument it kills all commodities.
  6. **  Arguments must be a list of Commodities.names
  7. **  Names are case sensitive.
  8. **
  9. **  29 Nov. 93
  10. **  09 Jan. 94 -- Mike Cuddy (fensende!mcuddy@apple.com)
  11. **        added 'DISABLE/ENABLE' argument (as first arg), to send
  12. **        CXCMD_DISABLE / CXCMD_ENABLE instead of CXCMD_KILL
  13. */
  14.  
  15. #include <exec/libraries.h>
  16. #include <exec/memory.h>
  17. #include <libraries/commodities.h>
  18. #include <dos/dos.h>
  19. #include <clib/exec_protos.h>
  20. #include <clib/alib_protos.h>
  21. #include <clib/commodities_protos.h>
  22.  
  23. UBYTE *version = "$VER: CxKiller 1.2";
  24.  
  25. #ifdef __SASC
  26. int CXBRK(void) { return(0); }  /* Disable SAS_C CTRL/C handling */
  27. int chkabort(void) { return(0); } 
  28. #include <pragmas/commodities_pragmas.h>
  29. #include <pragmas/exec_pragmas.h>
  30. #include <pragmas/dos_pragmas.h>
  31. #endif
  32.  
  33. /*** private functions of "commodities.library" ***/
  34.  
  35. #pragma libcall CxBase FindBroker 6c 801
  36. #pragma libcall CxBase CopyBrokerList ba 801
  37. #pragma libcall CxBase FreeBrokerList c0 801
  38. #pragma libcall CxBase BrokerCommand c6 802
  39.  
  40. CxObj *FindBroker(char *);
  41. LONG CopyBrokerList(struct List *);
  42. LONG FreeBrokerList(struct List *);
  43. LONG BrokerCommand(char *, LONG id);
  44.  
  45. struct Library *CxBase;
  46.  
  47. /*** private structures & defines ***/
  48.  
  49. struct BrokerCopy    {
  50.     struct Node    bc_Node;
  51.     char    bc_Name[CBD_NAMELEN];
  52.     char    bc_Title[CBD_TITLELEN];
  53.     char    bc_Descr[CBD_DESCRLEN];
  54.     LONG    bc_Task;
  55.     LONG    bc_Dummy1;
  56.     LONG    bc_Dummy2;
  57.     UWORD    bc_Flags;
  58. };
  59.  
  60. #define COF_ACTIVE 2
  61.  
  62.  
  63. __inline void 
  64. SendToAllBrokers (LONG Id)
  65. {
  66.     struct List *l;
  67.     struct Node *n, *nn;
  68.  
  69.     if (l = AllocVec(sizeof(struct List),MEMF_PUBLIC)) {
  70.         NewList(l);
  71.         CopyBrokerList(l);
  72.         for (n = l->lh_Head; n && (nn = n->ln_Succ); n = nn)
  73.             BrokerCommand((char *)((struct BrokerCopy *)n)->bc_Name,Id);
  74.         FreeBrokerList(l);
  75.         FreeVec(l);
  76.     }
  77. }
  78.  
  79. void 
  80. main(int argc, char *argv[])
  81. {
  82.     unsigned char i;
  83.     LONG Id = CXCMD_KILL;
  84.  
  85.     /* Before bothering with anything else, open the library */
  86.     if (CxBase = OpenLibrary("commodities.library", 37L))
  87.     {
  88.         if (argv[1]) {
  89.             if (stricmp(argv[1],"DISABLE")==0) {
  90.             Id = CXCMD_DISABLE;
  91.             argv++; argc--;
  92.             } else if (stricmp(argv[1],"ENABLE")==0) {
  93.             Id = CXCMD_ENABLE;
  94.             argv++; argc--;
  95.             }
  96.         }
  97.         if (argc < 2) 
  98.         {    /* no argument given, send to all brokers. */
  99.             SendToAllBrokers(Id);
  100.         }
  101.         else
  102.         {
  103.             for (i=1; i<argc ; i++)
  104.             {
  105.                 BrokerCommand((char *)argv[i], Id);
  106.             }
  107.         }
  108.     }
  109.     CloseLibrary(CxBase);
  110. }
  111.  
  112.  
  113.  
  114.